<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <h:form id="studentCerficate" styleClass="edit">

        <rich:panel>
            <f:facet name="header">#{studentCerficateHome.managed ? 'Edit' : 'Add'} Student cerficate</f:facet>


            <s:decorate id="idField" template="layout/edit.xhtml">
                <ui:define name="label">Id</ui:define>
                <h:inputText id="id"
                       required="true"
                       disabled="#{studentCerficateHome.managed}"
                          value="#{studentCerficateHome.instance.id}">
                    <a:support event="onblur" reRender="idField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>




            <s:decorate id="receivedStatusField" template="layout/edit.xhtml">
                <ui:define name="label">Received status</ui:define>
                <h:selectBooleanCheckbox id="receivedStatus"
                                   required="true"
                                      value="#{studentCerficateHome.instance.receivedStatus}"/>
            </s:decorate>


            <div style="clear:both">
                <span class="required">*</span>
                required fields
            </div>

        </rich:panel>

        <div class="actionButtons">

            <h:commandButton id="save"
                          value="Save"
                         action="#{studentCerficateHome.persist}"
                       disabled="#{!studentCerficateHome.wired}"
                       rendered="#{!studentCerficateHome.managed}"/>

            <h:commandButton id="update"
                          value="Save"
                         action="#{studentCerficateHome.update}"
                       rendered="#{studentCerficateHome.managed}"/>

            <h:commandButton id="delete"
                          value="Delete"
                         action="#{studentCerficateHome.remove}"
                      immediate="true"
                       rendered="#{studentCerficateHome.managed}"/>

            <s:button id="cancelEdit"
                   value="Cancel"
             propagation="end"
                    view="/StudentCerficate.xhtml"
                rendered="#{studentCerficateHome.managed}"/>

            <s:button id="cancelAdd"
                   value="Cancel"
             propagation="end"
                    view="/#{empty studentCerficateFrom ? 'StudentCerficateList' : studentCerficateFrom}.xhtml"
                rendered="#{!studentCerficateHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">

    <rich:tab label="Student *" labelClass="required">
    <div class="association" id="studentParent">

        <h:outputText value="There is no student associated with this studentCerficate."
                   rendered="#{studentCerficateHome.instance.student == null}"/>

        <rich:dataTable var="_student"
                   value="#{studentCerficateHome.instance.student}"
                rendered="#{studentCerficateHome.instance.student != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="studentTable">
            <h:column>
                <f:facet name="header">Id</f:facet>
                <h:outputText value="#{_student.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">UserAccount id</f:facet>
                <h:outputText value="#{_student.userAccount.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Course id</f:facet>
                <h:outputText value="#{_student.course.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">First name</f:facet>
                <h:outputText value="#{_student.firstName}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Last name</f:facet>
                <h:outputText value="#{_student.lastName}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Passport photo url</f:facet>
                <h:outputText value="#{_student.passportPhotoUrl}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Date of birth</f:facet>
                <h:outputText value="#{_student.dateOfBirth}">
                    <s:convertDateTime type="date" dateStyle="short"/>
                </h:outputText>
            </h:column>
            <h:column>
                <f:facet name="header">Register number</f:facet>
                <h:outputText value="#{_student.registerNumber}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Roll number</f:facet>
                <h:outputText value="#{_student.rollNumber}"/>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            
            <s:button id="#{studentCerficateHome.instance.student != null ? 'changeParentstudent' : 'selectParentstudent'}" value="#{studentCerficateHome.instance.student != null ? 'Change' : 'Select'} student"
                       view="/StudentList.xhtml">
                       
                       
                <f:param name="from" value="StudentCerficateEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>

    <rich:tab label="Certificate *" labelClass="required">
    <div class="association" id="certificateParent">

        <h:outputText value="There is no certificate associated with this studentCerficate."
                   rendered="#{studentCerficateHome.instance.certificate == null}"/>

        <rich:dataTable var="_certificate"
                   value="#{studentCerficateHome.instance.certificate}"
                rendered="#{studentCerficateHome.instance.certificate != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="certificateTable">
            <h:column>
                <f:facet name="header">Id</f:facet>
                <h:outputText value="#{_certificate.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Certificate name</f:facet>
                <h:outputText value="#{_certificate.certificateName}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Description</f:facet>
                <h:outputText value="#{_certificate.description}"/>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            
            <s:button id="#{studentCerficateHome.instance.certificate != null ? 'changeParentcertificate' : 'selectParentcertificate'}" value="#{studentCerficateHome.instance.certificate != null ? 'Change' : 'Select'} certificate"
                       view="/CertificateList.xhtml">
                       
                       
                <f:param name="from" value="StudentCerficateEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>

    <rich:tab label="Student certificate locations">
        <h:form styleClass="association" id="studentCertificateLocationsChildren">

            <h:outputText value="There are no studentCertificateLocations associated with this studentCerficate."
                       rendered="#{empty studentCerficateHome.studentCertificateLocations}"/>

            <rich:dataTable value="#{studentCerficateHome.studentCertificateLocations}"
                           var="_studentCertificateLocation"
                      rendered="#{not empty studentCerficateHome.studentCertificateLocations}"
                    rowClasses="rvgRowOne,rvgRowTwo"
                            id="studentCertificateLocationsTable">
                <rich:column sortBy="#{_studentCertificateLocation.id}">
                    <f:facet name="header">Id</f:facet>
                    <h:outputText value="#{_studentCertificateLocation.id}"/>
                </rich:column>
                <rich:column sortBy="#{_studentCertificateLocation.locationUrl}">
                    <f:facet name="header">Location url</f:facet>
                    <h:outputText value="#{_studentCertificateLocation.locationUrl}"/>
                </rich:column>
            </rich:dataTable>

        </h:form>

        <f:subview rendered="#{studentCerficateHome.managed}" id="studentCertificateLocations">
        <div class="actionButtons">
            <s:button id="addstudentCertificateLocation"
                   value="Add studentCertificateLocation"
                    view="/StudentCertificateLocationEdit.xhtml"
             propagation="none">
                 <f:param name="studentCerficateId"
                         value="#{studentCerficateHome.instance.id}"/>
                 <f:param name="studentCertificateLocationFrom" value="StudentCerficate"/>
            </s:button>
        </div>
        </f:subview>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
